package com.gjintel.business.report.controller;

import com.gjintel.auction.business.model.AuctionInfo;
import com.gjintel.business.proj.model.DepositReturn;
import com.gjintel.business.proj.model.ProjectInfo;
import com.gjintel.business.report.service.IAuctionReportService;
import com.gjintel.framework.constant.Constant;
import com.gjintel.framework.dict.model.Dictionary;
import com.gjintel.framework.projecttype.model.ProjectType;
import com.gjintel.framework.projecttype.service.IProjectTypeService;
import com.gjintel.framework.register.model.DepositCategory;
import com.gjintel.framework.util.CommUtil;
import com.gjintel.framework.util.DictUtil;
import com.gjintel.sdk.base.dao.Page;
import com.gjintel.sdk.base.dao.Sort;
import com.gjintel.sdk.common.mvc.IExcel;
import com.gjintel.sdk.common.mvc.JXLExcelView;
import com.gjintel.sdk.util.StringUtil;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@SuppressWarnings("all")
@Controller
@RequestMapping("business/auctionReport")
public class AuctionReportController {

	@Autowired
	private IAuctionReportService auctionReportService;

	@Autowired
	private IProjectTypeService projectTypeService;


	/**
	 * 保证金已退还状态1
	 */
	private Integer RETURNED_STATUS=1;

	/**
	 * 交易项目情况统计页面
	 * @return
	 */
	@RequestMapping("tradeProjectCase")
	public ModelAndView tradeProjectCase(){
		ModelAndView mv = new ModelAndView("/report/auctionTradeProjectCase-list");
		List<ProjectType> projectTypeList = projectTypeService.findAll();
		mv.addObject("projectTypeList", projectTypeList);
    	return mv;
	}

	/**
	 * @description 协议保证金统计
	 * @author shy
	 * @return mv
	 */
	@RequestMapping("/protocolDeposit")
    public ModelAndView protocolDeposit(){
    	ModelAndView mv = new ModelAndView();
    	List<DepositCategory> list = auctionReportService.listAuction();
    	mv.addObject("list", list);
    	mv.setViewName("report/protocol-deposit");
    	return mv;
    }


	/**
	 * @description 协议保证金统计  导出Excle
	 * @author shy
	 * @return mv
	 */
	@RequestMapping("/protocolDepositExport")
	public ModelAndView protocolDepositExport(){
    	List<DepositCategory> list = auctionReportService.listAuction();

    	 // 组合excel信息
		 String excelName = "协议保证金统计报表.xls";
		 String titles[] = {  "服务类型", "人数"};
		 String dbColumnNames[] = {"name", "count"};
		 Integer colWidth[] = { 50, 50, 50};

		 // Excel操作
		 Map model = new HashMap();
		 model.put("list", list);
		 model.put("titles", titles);
		 model.put("columns", dbColumnNames);
		 model.put(IExcel.COL_WIDTH, colWidth);
		 model.put("fileName", excelName);
		 model.put("sheetName", "协议保证金统计");
		 ModelAndView mv = new ModelAndView(new JXLExcelView(), model);

		 // 判断数据量(Excel只支持最大65536行)
		if (list.size() >= 65530) {
			mv.addObject("excel_error", "数据量过大!");
			return null;
		}
    	return mv;


	}

	/**
     * @description 进入保证金明细页面
     *
     */
	@RequestMapping("/depositListPage")
    public ModelAndView protocolDepositPage(){
    	ModelAndView mv = new ModelAndView();
    	List<ProjectType> projectTypeList = projectTypeService.findAll();
		mv.addObject("projectTypeList", projectTypeList);
    	mv.setViewName("report/project-deposit");
    	return mv;
    }


     /**
      * @description 保证金明细
      * @param projectName
      * @param code
      * @param page
      * @return
     * @throws IOException
      */

	@RequestMapping("/depositList")
	@ResponseBody
	public void getDepositList(String projectName, String code, Page page, Integer depositType, String projectType, HttpServletResponse resp) throws IOException{
		List<DepositReturn> list = this.auctionReportService.getAuctionDepositList(projectName,code,page,depositType,projectType);
		JSONObject jsonObject = CommUtil.getPageJSONData(page, true);
		resp.getWriter().print(jsonObject);
	}

	 /**
     * @description 保证金明细导出
     * @param projectName
     * @param code
     * @param page
     * @return
    * @throws IOException
     */
	@RequestMapping("/depositListExport")
	@ResponseBody
	public ModelAndView getDepositListExport(String projectName,String code,Integer depositType, String projectType) throws IOException{
		List<DepositReturn> Exportlist = this.auctionReportService.getAuctionDepositListExport(projectName, code,depositType,projectType);
		for(DepositReturn depositReturn:Exportlist){
			if(depositReturn.getPk().getDepositType()==0){
				depositReturn.setDepositTypeExport("竞拍保证金");
			}else if(depositReturn.getPk().getDepositType()==1){
				depositReturn.setDepositTypeExport("履约保证金");
			}
			if(depositReturn.getStatus()==1){
				depositReturn.setOutAmount(depositReturn.getTnAmount());
			}
		}
		 // 组合excel信息
		 String excelName = "保证金明细.xls";
		 String titles[] = {  "项目名称", "项目编号","项目类型","保证金类型","进账时间","借方发生额-进账","支出时间","贷方发生额-支出","对方名称","对方账号","对方开户行名称"};
		 String dbColumnNames[] = {"projectName", "projectCode","projectType","depositTypeExport","transTime","tnAmount","returnTime","outAmount","pk.companyName","inAcct","bankName"};
		 Integer colWidth[] = {30, 30, 30,30, 30, 30,30, 30, 30,30, 30};
		 // Excel操作
		 Map model = new HashMap();
		 model.put("list", Exportlist);
		 model.put("titles", titles);
		 model.put("columns", dbColumnNames);
		 model.put(IExcel.COL_WIDTH, colWidth);
		 model.put("fileName", excelName);
		 model.put("sheetName", "保证金明细");
		 ModelAndView mv = new ModelAndView(new JXLExcelView(), model);

		 // 判断数据量(Excel只支持最大65536行)
		if (Exportlist.size() >= 65530) {
			mv.addObject("excel_error", "数据量过大!");
			return null;
		}
   	return mv;

	}

	/**
	 * 交易项目情况列表
	 * @param session
	 * @param auction
	 * @param page
	 * @param sort
	 * @param startTime
	 * @param stopTime
	 * @param startMoney
	 * @param endMoney
	 * @return
	 */
	@RequestMapping("/tradeProjectCaseList")
	@ResponseBody
	public JSONObject expertList(HttpSession session, AuctionInfo auction, Page page, Sort sort,
                                 java.sql.Date startTime, java.sql.Date stopTime) {
		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		auctionReportService.findAuctionReportByProjectCase(auction,page,sort,startTime,stopTime);
		List<AuctionInfo> result = page.getResult();
		for (AuctionInfo info : result) {
			Dictionary dicProStatus = DictUtil.dict("proj_status", info.getStatus() + "");
			if (dicProStatus != null) {
				info.setStatusName(dicProStatus.getName());// 项目状态
			} else {
				info.setStatusName("未知");// 项目状态
			}
		}
		return CommUtil.getPageJSONData(page, true);
	}

	/**
	 * 导出交易项目情况统计Excel
	 * @param session
	 * @param project
	 * @param sort
	 * @param startTime
	 * @param stopTime
	 * @param startMoney
	 * @param endMoney
	 * @return
	 */
	@RequestMapping(value = "/exportTradeProject", method = RequestMethod.POST)
	public ModelAndView export(HttpSession session, AuctionInfo auction, Sort sort, java.sql.Date startTime,
                               java.sql.Date stopTime) {

		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		List<AuctionInfo> list = auctionReportService.findAuctionReportByProjectCase(auction,null,sort,startTime,stopTime);

		for (AuctionInfo info : list) {
			Dictionary dicProStatus = DictUtil.dict("statusName", info.getStatus() + "");
			if (dicProStatus != null) {
				info.setStatusName(dicProStatus.getName());// 项目状态
			} else {
				info.setStatusName("未知");// 项目状态
			}
		}
		 // 组合excel信息
		 String excelName = "交易项目情况.xls";

		 String titles[] = { "项目名称", "项目类别", "产权人", "项目编号", "项目受理日期", "信息发布日期", "中标公示日期",
				 "中标单位" ,"中标金额(元)","交易时间","项目状态"};
		 String dbColumnNames[] = { "auctionName", "catagoryName","ownerName", "code", "createTime", "auctionShowStart",
		 "hitShowStart" ,"winnerName","hitPrice","tradeTime","statusName"};
		 Integer colWidth[] = { 30, 30, 35, 30, 40, 40, 40,40,40,40,40 };


		 // Excel操作
		 Map model = new HashMap();

		 model.put("list", list);
		 model.put("titles", titles);
		 model.put("columns", dbColumnNames);
		 model.put(IExcel.COL_WIDTH, colWidth);
		 model.put("fileName", excelName);
		 model.put("sheetName", "交易项目情况统计");
		 ModelAndView mv = new ModelAndView(new JXLExcelView(), model);

		 // 判断数据量(Excel只支持最大65536行)
		if (list.size() >= 65530) {
			mv.addObject("excel_error", "数据量过大!");
			return null;
		}

		return mv;
	}

	/**
	 * 保证金按时间段统计页面
	 * @return
	 */
	@RequestMapping("depositTime")
	public ModelAndView depositTime(java.sql.Date startTime, java.sql.Date stopTime){
		ModelAndView mv = new ModelAndView("/report/auctionDeposit-time");
		mv.addObject("startTime", startTime);
		mv.addObject("stopTime", stopTime);

		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		//====系统内================
		//投标收入
		BigDecimal returnIncomeAmountIn=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_BIDDER,null,startTime,stopTime,"DepositReturn");
		//投标支出
		BigDecimal returnPayAmountIn=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_BIDDER,RETURNED_STATUS,startTime,stopTime,"DepositReturn");
		//====系统外=====
		//投标收入
		BigDecimal returnIncomeAmountOut=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_BIDDER,null,startTime,stopTime,"DepositReturnOut");
		//投标支出
		BigDecimal returnPayAmountOut=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_BIDDER,RETURNED_STATUS,startTime,stopTime,"DepositReturnOut");
		if(returnIncomeAmountIn==null){
			returnIncomeAmountIn=new BigDecimal(0);
		}
		if(returnPayAmountIn==null){
			returnPayAmountIn=new BigDecimal(0);
		}
		mv.addObject("returnIncomeAmount", returnIncomeAmountIn.add(returnIncomeAmountOut==null?new BigDecimal(0):returnIncomeAmountOut));
		mv.addObject("returnPayAmount", returnPayAmountIn.add(returnPayAmountOut==null?new BigDecimal(0):returnPayAmountOut));

		//====系统内=================
		//履约收入
		BigDecimal executeIncomeAmountIn=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_EXECUTE,null,startTime,stopTime,"DepositReturn");
		//履约支出
		BigDecimal executePayAmountIn=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_EXECUTE,RETURNED_STATUS,startTime,stopTime,"DepositReturn");
		//====系统外=====
		//履约收入
		BigDecimal executeIncomeAmountOut=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_EXECUTE,null,startTime,stopTime,"DepositReturnOut");
		//履约支出
		BigDecimal executePayAmountOut=this.auctionReportService.findAuctionDepositAmountByDate(Constant.DEPOSIT_TYPE_EXECUTE,RETURNED_STATUS,startTime,stopTime,"DepositReturnOut");
		if(executeIncomeAmountIn==null){
			executeIncomeAmountIn=new BigDecimal(0);
		}
		if(executePayAmountIn==null){
			executePayAmountIn=new BigDecimal(0);
		}
		mv.addObject("executeIncomeAmount", executeIncomeAmountIn.add(executeIncomeAmountOut==null?new BigDecimal(0):executeIncomeAmountOut));
		mv.addObject("executePayAmount", executePayAmountIn.add(executePayAmountOut==null?new BigDecimal(0):executePayAmountOut));

		return mv;
	}

	/**
	 * 打开保证金明细页面
	 * @param startTime
	 * @param stopTime
	 * @return
	 */
	@RequestMapping("getDepositDetails")
	public ModelAndView getDepositDetails(Integer depositType,Integer status,java.sql.Date startTime, java.sql.Date stopTime){
		ModelAndView mv = new ModelAndView();
		if(status==RETURNED_STATUS){//支出
			if (Constant.DEPOSIT_TYPE_BIDDER==depositType) {
				mv.setViewName("/report/deposit-return-pay-details");//投标保证金支出页面
			}else{
				mv.setViewName("/report/deposit-execute-pay-details");//履约保证金支出页面
			}
		}else{//收入
			if (Constant.DEPOSIT_TYPE_BIDDER==depositType) {
				mv.setViewName("/report/deposit-return-income-details");//投标保证金收入页面
			}else{
				mv.setViewName("/report/deposit-execute-income-details");//履约保证金收入页面
			}
		}
		mv.addObject("depositType", depositType);
		mv.addObject("status", status);
		mv.addObject("startTime", startTime);
		mv.addObject("stopTime", stopTime);

		return mv;
	}

	/**
	 * 保证金明细列表
	 * @param className
	 * @param satus
	 * @return
	 */
	@RequestMapping("/depositDetailsList")
	@ResponseBody
	public JSONObject depositDetailsList(Page page, Integer depositType, Integer status, java.sql.Date startTime, java.sql.Date stopTime, String className){
		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		this.auctionReportService.findAuctionDepositListByDate(page,depositType,status,startTime,stopTime,className);//履约保证金
		return CommUtil.getPageJSONData(page, true);
	}


	/**
	 * 按时间段来统计的保证金明细报表Excel导出
	 * @param depositType
	 * @param status
	 * @param startTime
	 * @param stopTime
	 * @return
	 */
	@RequestMapping(value = "/exportDepositDetails")
	public ModelAndView exportDepositDetails(Integer depositType,Integer status,java.sql.Date startTime, java.sql.Date stopTime,String className) {
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		List list=new ArrayList<>();
		// 组合excel信息
		String excelName = "";
		String sheetName="按时间段统计";

		// Excel操作
		Map model = new HashMap();
		if(status==RETURNED_STATUS){//支出
			if (Constant.DEPOSIT_TYPE_BIDDER==depositType) {//投标保证金支出页面
				excelName="采购中心竞拍保证金明细单.xls";
				String titles[]={"项目名称","项目编号","项目类型","支出时间","支出金额","对方名称","对方账号","对方开户行"};
				String dbColumnNames[]={"projectName","projectCode","projectType","returnTime","tnAmount","pk.companyName","inAcct","bankName"};
				Integer colWidth[]={30, 30, 35, 30, 30, 40, 40, 40, 40};

				model.put("titles", titles);
				model.put("columns", dbColumnNames);
				model.put(IExcel.COL_WIDTH, colWidth);
				model.put("fileName", excelName);
				model.put("sheetName", sheetName);

			}else{//履约保证金支出页面
				excelName="采购中心履约保证金明细单.xls";
				String titles[]={"项目名称","项目编号","项目类型","支出时间","支出金额","对方名称","对方账号","对方开户行"};
				String dbColumnNames[]={"projectName","projectCode","projectType","returnTime","tnAmount","pk.companyName","inAcct","bankName"};
				Integer colWidth[]={30, 30, 35, 30, 30, 40, 40, 40, 40};

				model.put("titles", titles);
				model.put("columns", dbColumnNames);
				model.put(IExcel.COL_WIDTH, colWidth);
				model.put("fileName", excelName);
				model.put("sheetName", sheetName);
			}
		}else{//收入
			if (Constant.DEPOSIT_TYPE_BIDDER==depositType) {//投标保证金收入页面
				excelName="采购中心竞拍保证金明细单.xls";
				String titles[]={"项目名称","项目编号","项目类型","收入时间","收入金额","对方名称","对方账号","对方开户行"};
				String dbColumnNames[]={"projectName","projectCode","projectType","transTime","tnAmount","pk.companyName","inAcct","bankName"};
				Integer colWidth[]={30, 30, 35, 30, 30, 40, 40, 40, 40};

				model.put("titles", titles);
				model.put("columns", dbColumnNames);
				model.put(IExcel.COL_WIDTH, colWidth);
				model.put("fileName", excelName);
				model.put("sheetName", sheetName);

			}else{//履约保证金收入页面
				excelName="采购中心履约保证金明细单.xls";
				String titles[]={"项目名称","项目编号","项目类型","收入时间","收入金额","对方名称","对方账号","对方开户行"};
				String dbColumnNames[]={"projectName","projectCode","projectType","transTime","tnAmount","pk.companyName","inAcct","bankName"};
				Integer colWidth[]={30, 30, 35, 30, 30, 40, 40, 40, 40};

				model.put("titles", titles);
				model.put("columns", dbColumnNames);
				model.put(IExcel.COL_WIDTH, colWidth);
				model.put("fileName", excelName);
				model.put("sheetName", sheetName);
			}
		}

		if (Constant.DEPOSIT_TYPE_BIDDER==depositType) {
			list=this.auctionReportService.findAuctionDepositListByDate(null,depositType,status,startTime,stopTime,className);//投标保证金
		}else{
			list=this.auctionReportService.findAuctionDepositListByDate(null,depositType,status,startTime,stopTime,className);//履约保证金
		}
		model.put("list", list);//数据源
		//生成excel
		ModelAndView mv = new ModelAndView(new JXLExcelView(), model);

		// 判断数据量(Excel只支持最大65536行)
		if (list.size() >= 65530) {
			mv.addObject("excel_error", "数据量过大!");
			return null;
		}

		return mv;
	}

	/**
	 * 消息管理员导出项目页面
	 * @return
	 */
	@RequestMapping("messageProjectReport")
	public ModelAndView messageProjectReport(HttpSession session){
		ModelAndView mv = new ModelAndView("/report/export-project-list");
    	return mv;
	}

	/**
	 * 消息管理员导出项目list
	 * @param session
	 * @param project
	 * @param page
	 * @param sort
	 * @param startTime
	 * @param stopTime
	 * @param startMoney
	 * @param endMoney
	 * @return
	 */
	@RequestMapping("/exportProjectList")
	@ResponseBody
	public JSONObject exportProjectList(HttpSession session, ProjectInfo project, Page page, Sort sort,
                                        java.sql.Date startTime, java.sql.Date stopTime) {
		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		auctionReportService.findAuctionReportByProjectList(project,page,sort,startTime,stopTime);

		List<ProjectInfo> result = page.getResult();
		for (ProjectInfo pro : result) {
			Dictionary dicProStatus = DictUtil.dict("proj_status", pro.getStatus() + "");
			if (dicProStatus != null) {
				pro.setStatusName(dicProStatus.getName());// 项目状态
			} else {
				pro.setStatusName("未知");// 项目状态
			}
		}
		return CommUtil.getPageJSONData(page, true);
	}


	/**
	 * 信息管理员导出项目到Excel
	 * @param session
	 * @param project
	 * @param sort
	 * @param startTime
	 * @param stopTime
	 * @param startMoney
	 * @param endMoney
	 * @return
	 */
	@RequestMapping(value = "/exportProjectReport")
	public ModelAndView exportProjectReport(HttpSession session, ProjectInfo project, Page page, Sort sort,
                                            java.sql.Date startTime, java.sql.Date stopTime) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
		String excelName ="";
		if(startTime!=null&&stopTime!=null){
			excelName = "竞拍项目("+sdf.format(startTime)+"--"+sdf.format(stopTime)+")信息.xls";
		}else{
			excelName = "竞拍项目信息.xls";
		}

		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		List<ProjectInfo> list = auctionReportService.findAuctionReportByProjectList(project, null, sort, startTime, stopTime);

		// 组合excel信息

		String titles[] = { "项目编号","项目名称", "项目类型 ", "产权单位","预算金额(元)", "竞拍时间 ", "项目负责人"};
		String dbColumnNames[] = { "code","name", "catagoryName", "agentName", "budgetAmount", "bidStartTime", "manageName"};
		Integer colWidth[] = { 30, 30, 35, 30, 30, 40, 40, 40};

		// Excel操作
		Map model = new HashMap();

		model.put("list", list);
		model.put("titles", titles);
		model.put("columns", dbColumnNames);
		model.put(IExcel.COL_WIDTH, colWidth);
		model.put("fileName", excelName);
		model.put("sheetName", "项目信息");
		ModelAndView mv = new ModelAndView(new JXLExcelView(), model);

		// 判断数据量(Excel只支持最大65536行)
		if (list.size() >= 65530) {
			mv.addObject("excel_error", "数据量过大!");
			return null;
		}

		return mv;
	}




	/**
	 * 分配人导出未开标项目页面
	 * @return
	 */
	@RequestMapping("assignProjectReport")
	public ModelAndView assignProjectReport(HttpSession session,Boolean auditable){
		ModelAndView mv = new ModelAndView("/report/assign-export-project-list");
		mv.addObject("auditable",auditable);
    	return mv;
	}

	/**
	 * 分配人导出未开标项目list
	 * @param session
	 * @param project
	 * @param page
	 * @param sort
	 * @param startTime
	 * @param stopTime
	 * @param startMoney
	 * @param endMoney
	 * @return
	 */
	@RequestMapping("/assignExportProjectList")
	@ResponseBody
	public JSONObject assignExportProjectList(HttpSession session, ProjectInfo project, Page page, Sort sort,
                                              java.sql.Date startTime, java.sql.Date stopTime) {
		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		auctionReportService.findAuctionReportByNoOpentBidProjectList(project,page,sort,startTime,stopTime);

		List<ProjectInfo> result = page.getResult();
		for (ProjectInfo pro : result) {
			Dictionary dicProStatus = DictUtil.dict("proj_status", pro.getStatus() + "");
			if (dicProStatus != null) {
				pro.setStatusName(dicProStatus.getName());// 项目状态
			} else {
				pro.setStatusName("未知");// 项目状态
			}
		}
		return CommUtil.getPageJSONData(page, true);
	}


	/**
	 * 分配人导出未开标项目到Excel
	 * @param session
	 * @param project
	 * @param sort
	 * @param startTime
	 * @param stopTime
	 * @param startMoney
	 * @param endMoney
	 * @return
	 */
	@RequestMapping(value = "/assignExportProjectReport")
	public ModelAndView assignExportProjectReport(HttpSession session, ProjectInfo project, Page page, Sort sort,
                                                  java.sql.Date startTime, java.sql.Date stopTime) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
		String excelName ="";
		if(startTime!=null&&stopTime!=null){
			excelName = "未竞拍项目("+sdf.format(startTime)+"--"+sdf.format(stopTime)+")信息.xls";
		}else{
			excelName = "未竞拍项目信息.xls";
		}

		// 结束时间处理，加一天
		stopTime = StringUtil.addOneDayDate(stopTime, 1);
		List<ProjectInfo> list = auctionReportService.findAuctionReportByNoOpentBidProjectList(project, null, sort, startTime, stopTime);

		// 组合excel信息

		String titles[] = { "项目编号","项目名称", "项目类型 ", "产权单位","预算金额(元)", "竞拍时间 ", "项目负责人"};
		String dbColumnNames[] = { "code","name", "catagoryName", "agentName", "budgetAmount", "bidStartTime", "manageName"};
		Integer colWidth[] = { 30, 30, 35, 30, 30, 40, 40, 40};

		// Excel操作
		Map model = new HashMap();

		model.put("list", list);
		model.put("titles", titles);
		model.put("columns", dbColumnNames);
		model.put(IExcel.COL_WIDTH, colWidth);
		model.put("fileName", excelName);
		model.put("sheetName", "项目信息");
		ModelAndView mv = new ModelAndView(new JXLExcelView(), model);

		// 判断数据量(Excel只支持最大65536行)
		if (list.size() >= 65530) {
			mv.addObject("excel_error", "数据量过大!");
			return null;
		}

		return mv;
	}
}
